package com.englisheveryday.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;

/**
 * <pre>
 *       系统环境监测工具类
 * </pre>
 * @author 马永华
 * @date 2012-10-17 上午10:49:43
 * @version 1.1
 */

public class EnvironmentCheckUtil {

	//判断SD卡状态
	public static boolean SDCardCheck(){
		return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
	}
	
	//判断网络连接
	public static boolean isNetworkAvailable(Context context){
		ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		if(cm!=null){
			NetworkInfo[] networks = cm.getAllNetworkInfo();
			for(NetworkInfo info : networks){
				L.d("网络类型："+info.getTypeName());
				if(info.isConnected()){
					return true;
				}
			}
		}
		return false;
	}
}

